package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.Region;
import cn.wolfcode.luowowo.article.domain.Route;
import cn.wolfcode.luowowo.article.mapper.RouteMapper;
import cn.wolfcode.luowowo.article.service.IRouteService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class RouteServiceImpl implements IRouteService {
    @Autowired
    private RouteMapper routeMapper;
    @Override
    public void saveOrUpdate(Route route) {
        if(route.getId()!=null){
            routeMapper.updateByPrimaryKey(route);
        }else {
            routeMapper.insert(route);
        }
    }

    @Override
    public Region get(Long rid) {
        return null;
    }

    @Override
    public List<Route> queryHotRegions() {
        return null;
    }

    @Override
    public List<Route> list() {
        return routeMapper.selectAll();
    }

    @Override
    public Route selectMaxHotRouteWithDestId(Long id) {
        List<Route> routes = routeMapper.selectByDestId(id);
        if(routes.size()>0){
            return routes.get(0);
        }
        return null;
    }
}
